Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@multiformats/multiaddr

Package Overview
Dependencies
Maintainers
10
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@multiformats/multiaddr

multiaddr implementation (binary + string representation of network addresses)

  • 12.3.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
206K
increased by0.68%
Maintainers
10
Weekly downloads
 
Created

What is @multiformats/multiaddr?

@multiformats/multiaddr is a JavaScript implementation of the multiaddr format, which is a self-describing network address format. It is used to represent addresses in a way that is protocol-agnostic and can be easily extended to support new protocols.

What are @multiformats/multiaddr's main functionalities?

Create a Multiaddr

This feature allows you to create a new multiaddr instance from a string. The example demonstrates creating a multiaddr for an IPv4 address with a TCP port.

const multiaddr = require('@multiformats/multiaddr');
const addr = multiaddr('/ip4/127.0.0.1/tcp/4001');
console.log(addr.toString());

Parse a Multiaddr

This feature allows you to parse a multiaddr and extract protocol names. The example shows how to get the protocol names from a multiaddr.

const multiaddr = require('@multiformats/multiaddr');
const addr = multiaddr('/ip4/127.0.0.1/tcp/4001');
console.log(addr.protoNames());

Encapsulate and Decapsulate

This feature allows you to encapsulate and decapsulate addresses. The example demonstrates adding a UDP layer to an existing address and then removing it.

const multiaddr = require('@multiformats/multiaddr');
const addr = multiaddr('/ip4/127.0.0.1/tcp/4001');
const encapsulated = addr.encapsulate('/udp/1234');
console.log(encapsulated.toString());
const decapsulated = encapsulated.decapsulate('/udp');
console.log(decapsulated.toString());

Other packages similar to @multiformats/multiaddr

Keywords

FAQs

Package last updated on 03 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc